package com.laiyw.monitor.controller;

import com.alibaba.fastjson.JSONObject;
import com.laiyw.monitor.core.annotation.Autowired;
import com.laiyw.monitor.core.annotation.Controller;
import com.laiyw.monitor.core.annotation.RequestMapping;
import com.laiyw.monitor.service.MonitorService;

import java.util.List;

/**
 * @Description:
 * @Auther: Laiyw
 * @Date: 2018/10/5 9:23
 */
@Controller
public class MonitorController {

    @Autowired
    private MonitorService service;

    @RequestMapping("/dashboard.json")
    public JSONObject getDashboard() {
        return service.getDashboard();
    }

    /**
     * 服务器信息
     *
     * @return
     */
    @RequestMapping("/server.json")
    public JSONObject getServerInfo() {
        return service.getServerInfo();
    }

    /**
     * Java虚拟机信息
     *
     * @return
     */
    @RequestMapping("/jvm.json")
    public JSONObject getJvmInfo() {
        return service.getJvmInfo();
    }

    /**
     * 服务器处理器信息
     *
     * @return
     */
    @RequestMapping("/cpu.json")
    public List<JSONObject> getServerCpuListInfo() {
        return service.getServerCpuListInfo();
    }

    /**
     * 内存
     * 服务器：物理内存，交换区内存
     * Java虚拟机：总内存，堆/非堆内存，堆/非堆内存详细信息
     *
     * @return
     */
    @RequestMapping("/memory.json")
    public JSONObject getMemory() {
        return service.getMemory();
    }

    @RequestMapping("/gc.json")
    public void gc() {
        System.gc();
    }

    /**
     * 服务器磁盘信息
     *
     * @return
     */
    @RequestMapping("/disk.json")
    public List<JSONObject> getServerDisk() {
        return service.getServerDisk();
    }

}
